package com.example.usermanagement.exception;

import com.example.usermanagement.common.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import lombok.extern.slf4j.Slf4j;

@Slf4j
@RestControllerAdvice
public class ErrorSystem {

    @ExceptionHandler(Exception.class)
    public Result<Void> handleException(Exception e) {
        // 记录异常信息到日志
        log.error("系统异常", e);
        return Result.error(e.getMessage() != null ? e.getMessage() : "系统异常，请联系管理员");
    }
} 